package integracion.converters;

import integracion.converters.entidades.Articulo;
import integracion.converters.entidades.ItemVenta;
import integracion.converters.entidades.Log;
import integracion.converters.entidades.Resultado;
import integracion.converters.entidades.Venta;

import java.io.IOException;

import portal.vo.ProductoVO;

import com.thoughtworks.xstream.XStream;

public abstract class AbstractXmlConverter<T extends portal.vo.AbstractVO> {

	/**
	 * Primera linea del archivo xml
	 */
	protected static final String XML_VERSION = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n";

	/**
	 * Devuelve una instancia de XStream
	 */
	protected XStream getXStreamArticulo() {
		XStream xstream = new XStream();
		xstream.alias("articulo", Articulo.class);
		return xstream;
	}
	
	protected XStream getXStreamVenta() {
		XStream xstream = new XStream();
		xstream.alias("venta", Venta.class);
		xstream.alias("item", ItemVenta.class);
		return xstream;
	}
	
	protected XStream getXStreamResultado() {
		XStream xstream = new XStream();
		xstream.alias("resultado", Resultado.class);
		return xstream;
	}
	
	protected XStream getXStreamLog() {
		XStream xstream = new XStream();
		xstream.alias("log", Log.class);
		return xstream;
	}
	
	
	
	/**
	 * Devuelve el VO a partir del xml (String)
	 * 
	 * @param xml
	 * @return
	 * @throws ErrorEnXmlException
	 */
	public ProductoVO getVO(String xml) throws ErrorEnXmlException {
		throw new UnsupportedOperationException();
	}

	
	/**
	 * Devuelve un string con el xml cargado
	 * 
	 * @param stream
	 * @return
	 * @throws IOException
	 */
	public String getXml(T vo) throws ErrorEnXmlException {
		throw new UnsupportedOperationException();
	}
}
